using System;
using L=Science.Physics.GeneralPhysics;

namespace Serway.Chapter32
{
	/// <summary>
	/// Example07: Oscillations in a LC Circuit
	/// In Figure 32.20, the capacitor is initially charged 
	/// when switch S_1 is open and S_2 is closed.  Switch S_2 is 
	/// then opened, removing the battery from the circuit, and 
	/// the capacitor remains charged. Switch S_1 is then closed, 
	/// so that the capacitor is connected directly across the inductor.
	/// (A)	Find the frequency of oscillation of the circuit.
	/// (B)	What are the maximum values of charge on the capacitor 
	/// and current in the circuit?
	/// (C)	Determine the charge and current as functions of time.
	/// </summary>
	public class Example07
	{
		public Example07()
		{
		}
		private string result;
		public string Result
		{
			get{return result;}
		}
		public void Compute()
		{
			L.Inductance LL = new L.Inductance();
			LL.H = 2.81E-3;
			L.Capacitance C = new L.Capacitance();
			C.F = 9.0E-12;
			L.CircuitLC cir = new L.CircuitLC(LL,C);
			//(A)
			result+=Convert.ToString(cir.NaturalFrequency)+"\r\n";
			//(B)
			L.ElectricPotentialDifference V 
				= new L.ElectricPotentialDifference();
			V.V = 12.0;
			L.ElectricCharge q = new L.ElectricCharge(C,V);
			result+=Convert.ToString(q.C)+"\r\n";
			L.ElectricCurrent I = new L.ElectricCurrent();
			I.A = 2.0*Math.PI*cir.NaturalFrequency*q.C;
			result+=Convert.ToString(I.A)+"\r\n";
			//(C)
			result += "Read the book!";
		}
	}
}